package arrays.双指针;

import com.google.common.collect.Lists;

import java.io.IOException;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.IntStream;

/**
 * todo
 *
 * @author songZiHao
 * @version 1.0.0
 * @ClassName 删除有序数组中的重复项26.java
 * @createTime 2022年07月28日 11:04:00
 */
public class 删除有序数组中的重复项26 {
    public int removeDuplicates(int[] nums) {
        if (nums.length == 0) {
            return 0;
        }
        int slow = 0;
        int fast = 0;
        while (fast < nums.length) {
            if (nums[fast] != nums[slow]) {
                slow++;
                nums[slow] = nums[fast];
            }
            fast++;
        }
        return slow + 1;

    }
}
